package com.yuanfeng.activity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanfeng.activity.dto.GetAvailableVcBaseDTO;
import com.yuanfeng.activity.dto.UserGetVoucherParamDTO;
import com.yuanfeng.activity.dto.UserVcBaseDTO;
import com.yuanfeng.activity.entity.ActivityVoucherBaseEntity;
import com.yuanfeng.activity.vo.*;
import com.yuanfeng.commoms.vo.activity.VoucherBaseVO;
import com.yuanfeng.commoms.vo.activity.YfVoucherBaseVO;
import com.yuanfeng.commoms.vo.goods.GdsListQueryResultVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @ClassName ActivityVoucherBaseMapper
 * @Description 代金券表
 * @Author cyp
 * @Date 2023-05-25 16:55:50
 * @Version 1.0
 **/
@Mapper
public interface ActivityVoucherBaseMapper extends BaseMapper<ActivityVoucherBaseEntity> {

    /**
     * 根据店铺id查询代金券信息
     * @param param
     * @return
     */
    List<YfVoucherTemplateVO> selectVoucherTempByShopId(@Param("param") GetAvailableVcBaseDTO param);

    /**
     * 判断代金券是否领取过
     * @param param
     * @return
     */
    Integer checkReceivedOrNot(@Param("param") GetAvailableVcBaseDTO param);

    /**
     * 代金卷优惠
     *
     * @param map
     * @return
     */
    VoucherBaseVO getVoucherDetail(@Param("param") Map<String, Object> map);
    /**
     * 查询goodsid
     *
     * @param voucherId
     * @return
     */
    List<Integer> selectAvaliableGoods(@Param("voucherId") Integer voucherId);

    /**
     * 更新优惠券状态
     * @param voucherMap
     * @return
     */
    Integer updateVoucherDetail(Map<String, String> voucherMap);

    /**
     * 商品是否是经销商品
     * @param goodsId
     * @return
     */
    GoodsIdsQueryResultVO selectGoodsIdList(@Param("goodsId")Integer goodsId);

    /**
     * 查询优惠券
     * @param checkMap
     * @return
     */
    List<YfVoucherBaseVO> selectVcBase(@Param("param")Map<String, Object> checkMap);

    /**
     * 判断优惠券是否领取过
     * @param param
     * @return
     */
    Integer checkVoucherOrNot(@Param("param")UserGetVoucherParamDTO param);
    /**
     * 查询优惠券信息
     */
    UserGetVoucherUpdateParamVO selectVcTemById(@Param("param")UserGetVoucherParamDTO param);

    /**
     * 插入用户领取信息
     * @param voucherTemplate
     */
    void insertyfVoucherBase(@Param("param")UserGetVoucherUpdateParamVO voucherTemplate);

    /**
     * 更新优惠券数量
     * @param param
     */
    void updateVoucherGiveout(@Param("param") UserGetVoucherParamDTO param);

    /**
     * 查询基础店铺
     *
     * @param page
     * @param param
     * @return
     */
    IPage<VoucherBaseVO> selectVcBaseByShopBase(Page<VoucherBaseVO> page, @Param("param") UserVcBaseDTO param);

    /**
     * 查询优惠券列表
     * @param param
     * @return
     */
    List<Integer> selectVoucherTIds(@Param("param")GetAvailableVcBaseDTO param);

    /**
     * 查询红包领取状态
     * @param param
     * @return
     */
    List<CheckReceivedVcOrNotResultVO> checkReceivedVcOrNot(@Param("param")GetAvailableVcBaseDTO param);

    /**
     * 查询优惠券信息
     * @param paraMap
     * @return
     */
    IPage<QueryShopVoucherTempResultVO> queryShopVoucherTempPort(IPage<QueryShopVoucherTempResultVO> page, @Param("param")Map<String, Object> paraMap);

    /**
     * 删除基础代金券
     *
     * @param paraMap
     */
    void deleteVoucherBase(Map<String, String> paraMap);

    List<GdsListQueryResultVO> queryShopVoucherGoodsById(Integer voucherTId);

    List<YfVoucherBaseVO> selectGoodsVcBase(@Param("commonId") Integer commonId,@Param("goodOrderPrice") Double goodOrderPrice,
                                            @Param("userId") String userId,@Param("shopId") String shopId,
                                            @Param("voucherIdList") List<Integer> voucherIdList);
}
